package com.liushuyv.calculator.simplefactory;

import com.liushuyv.calculator.bll.*;

/*
 **@Author:刘淑钰
 **Created on 2020/12/1
 */
public class SimpleFactory {
    public IOperation getOperation(String oprType) throws Exception {//类型，选最高层的，因为要返回的值是父类型的指针
        IOperation opr = null;
        switch (oprType) {
            case "+":
                opr = new AddOperation();
                break;
            case "-":
                opr = new SubOperation();
                break;//生成不同的模式
            default:
                throw new Exception("运算符错了");
        }
        return opr;
    }
}


